/**
 * Created by jianzhou on 2015/1/15.
 */
app.factory("registerService", ["basicHttp", function(basicHttp){
            var promise;
            var service = {
                register: function(options){

                    promise = basicHttp.http({
                        method: 'POST',
                        url: basicHttp.prefixUrl + "User/Register",
                        data: options
                    }).then(function(response){
                            return response.data;
                        });
                    return promise;
                },
                getShortMsgCode: function(options){
                   alert(options.phoneNum + options.behavior);
                    promise = basicHttp.http({
                        method: 'GET',
                        url: basicHttp.prefixUrl + "ShortMsgCode/Get",
                        params:options
                    }).then(function(response){
                        alert(response.data.friendlyMessage);
                        return response.data;
                    });
                    return promise;
                }
            };
            return service;
}]);

app.factory('doctorService', ["basicHttp", function(basicHttp){
    var response =
    {
        getInfo:function()
        {
            basicHttp.setAuthToken();
            var getResponse = basicHttp.http
            ({
                method:'GET',
                url:basicHttp.prefixUrl + "Doctor/GetProfile"
            }).then(function(resultData){return resultData.data;});
            return getResponse;
        },
        updataInfo:function(params)
        {
            basicHttp.setAuthToken();
            var updatadata = basicHttp.http
            ({
                method:'POST',
                url:basicHttp.prefixUrl + "Doctor/UpdateProfile",
                data:params
            }).then(function(reponseData_2){return reponseData_2.data;});
            return updatadata;
        },
        insertInfo:function(params)
        {
            basicHttp.setAuthToken();
            var insertData = basicHttp.http
            ({
                method:'POST',
                url:basicHttp.prefixUrl + "User/Register",
                data:params
            }).then(function(response){return response.data});
            return insertData;
        },
        getPhoneVerifyCode : function(options)
        {
            basicHttp.setAuthToken();
            var verifyCode = basicHttp.http
            ({
                method:"GET",
                url:basicHttp.prefixUrl + "ShortMsgCode/Get",
                params:options
            }).then(function(respons){
                //console.log(respons.data);
                return respons.data;
            });
            return verifyCode;
        },
        getDoctorList:function(options)
        {
            basicHttp.setAuthToken();
            var infoList = basicHttp.http
            ({
                method:'POST',
                url:basicHttp.prefixUrl + "Doctor/Search",
                data:options
            }).then(function(response){
                return response.data;
            });
            return infoList;
        },
        getDoctorExpertise:function()
        {
            basicHttp.setAuthToken();
            var expertiseList = basicHttp.http
            ({
                method:'GET',
                url:basicHttp.prefixUrl + 'Speciality/GetList'
            }).then(function(data){
                return data.data;
            });
            console.log(expertiseList);
            return expertiseList;
        },
        getMyCustomers:function()
        {
            basicHttp.setAuthToken();
            var myClientList = basicHttp.http({
                method:'GET',
                url:basicHttp.prefixUrl+ 'Doctor/GetMyCustomers'
            }).then(function(response){
                return response.data;
            });
            return myClientList;
        },
        getTopicsByReply:function(options){
            basicHttp.setAuthToken();
            var replyList = basicHttp.http({
                method:'GET',
                url:basicHttp.prefixUrl + 'SNS/GetTopicsByReply',
                params:options
            }).then(function(response){
                return response.data;
            });
            return replyList;
        },
        buyPlan:function(options){
            //alert(basicHttp.prefixUrl + 'Consultant/BuyPlan')
            basicHttp.setAuthToken();
            var buy = basicHttp.http({
                method:'POST',
                url:basicHttp.prefixUrl + 'Consultant/BuyPlan',
                params:options
            }).then(function(response){
                return response.data;
            });
            return buy;
        }
    };
    return response;
}])


